<template>
	<view>
		<view class="wrap_nb f12">
			{{ title }}({{ total }}人)
		</view>
		
		<view class="wrap_nb">
			<u-line></u-line>
		</view>
		
		<view class="wrap_nb dflex jcsb aic" v-for="(item, index) in followers" :key="index" @click="toMemberIndex" :data-currentuid="item.id">
			<u-image :src="item.avatar" width="60" shape="circle" height="60"></u-image>
			<text class="fg1 ml5">{{ item.name }}</text>
			<view class="f12 normal_follow_button">
				TA的主页
			</view>
		</view>
		
		<view class="empty_list" v-if="empty">				
			<u-empty mode="data" text="还没有粉丝哦~"></u-empty>
		</view>
		
		<version></version>
		
	</view>
</template>

<script>
	
	
	export default {
		data() {
			return {
				followers : [],
				total : '',
				empty : '',
				title : '我的粉丝'
			}
		},
		onLoad(e) {
			this.getFollowers(e.uid)
			if(!e.self == 1) {
				this.title = "他的粉丝"
			}
		},
		methods: {
			getFollowers(uid) {				
				//初始列表
				uni.showLoading({
					title:"加载中...."
				})
				uni.request({
					url:uni.getStorageSync('domain') + '/api/v1/users/' + uid + '/followers',
					method:'get',
					header: {
						'Accept': 'application/json',
						'Authorization' : 'Bearer ' + uni.getStorageSync('access_member_info').access_token
					},
					success: (res) => {
						this.followers = res.data.followers
						this.total = res.data.page.total
						if(res.data.page.total == 0) {
							this.empty = true
						}
						uni.hideLoading();
					},
					fail: (res) => {
					}
				})
			},
			toMemberIndex(e) {
				var uid = e.currentTarget.dataset.currentuid;				
				uni.navigateTo({
					url:"/pages/member/memberStranger?uid=" + uid
				})
			},
		}
	}
</script>

<style>

</style>
